﻿/*************************************************************************
File:   as/strm3.as
Author: Duykham
UpDate: 01/11/2006
TODO:   
/*************************************************************************/
echo("#included: strm3.as");
///////////////////////////////////////////////////////////////////////////
//TODO: included files
///////////////////////////////////////////////////////////////////////////
//TODO: khai bao bien
var positionArray = new Array();
var noOfCam = _global.arrayStream.length;

///////////////////////////////////////////////////////////////////////////
//TODO: initialize
if (noOfCam<5) {
	positionArray.push({x_value:30, y_value:70});
	positionArray.push({x_value:290, y_value:70});
	positionArray.push({x_value:30, y_value:280});
	positionArray.push({x_value:290, y_value:280});
}
//if (noOfCam>3 && noOfCam<7) {
	//positionArray.push({x_value:100, y_value:100});
	//positionArray.push({x_value:290, y_value:100});
	//positionArray.push({x_value:480, y_value:100});
	//positionArray.push({x_value:100, y_value:290});
	//positionArray.push({x_value:290, y_value:290});
	//positionArray.push({x_value:480, y_value:290});
//}
/////////////////////////////////////////////////////////////////////////// 
//TODO: initialize
//TODO: load stream
function loadCams() {
	//lan luot load Camera vao cac vi tri duoc dinh san
	for (i=0; i<noOfCam; i++) {
		var thisMC:MovieClip = _level0.createEmptyMovieClip("cam"+i+"_mc", i);
		thisMC._x = positionArray[i].x_value;
		thisMC._y = positionArray[i].y_value;
		thisMC.loadMovie("streamCam.swf");
		echo("camArray [i].label: "+camArray[i].label);
	}
}
//TODO: setCamerasValue ()
function setCamerasValue() {
	trace("setCamerasValue()");
	intervalID = setInterval(function () {
		setcamvalue(cam0_mc, 0);
		setcamvalue(cam1_mc, 1);
		setcamvalue(cam2_mc, 2);
		setcamvalue(cam3_mc, 3);
		setcamvalue(cam4_mc, 4);
		setcamvalue(cam5_mc, 5);
	}, 100);
}
//TODO: Set values for cameras
function setcamvalue(myMovie:MovieClip, num:Number) {
	//var thisCam:Camera = Camera.get(num);
	//myMovie.cam_vid.attachVideo(thisCam);
	myMovie.name_txt = _global.arrayStream[num].label;
}
this.onEnterFrame = function() 
{
	if (_level0.cam0_mc.name_txt != undefined && _level0.cam0_mc.name_txt != "" && _level0.cam0_mc.thisCam != undefined) {
		clearInterval(intervalID);
	}
	if (_global.arrayStream[0].label == undefined){
		gotoAndStop("strm1");
		//gotoAndStop("strm4");
	}
};
//Back button
back_btn.onRelease = function()
{		
		//_root.mySound.stop();
		unLoadMovies ();
		_global.arrayStream = new Array ();
		gotoAndStop ("strm1");
		//gotoAndStop ("strm4");
};

//On Load
loadCams();
setCamerasValue();
